<div class="page-container" v-cloak>
    <el-card>
        <template #header>
            <div class="breadcrumb" style=" overflow: hidden;">
                <el-breadcrumb separator="/" style=" float: left;  ">
                    <el-breadcrumb-item>{$title}</el-breadcrumb-item>
                </el-breadcrumb>
                <el-breadcrumb separator="/" style=" float: right;  ">
                    <el-button type="primary" @click="refresh()">刷新</el-button>
                </el-breadcrumb>
            </div>
        </template>
        <div>
            <el-form label-width="100px">
                <el-form-item label="所属门店">
                    <div>
                        <el-radio-group v-model="form.store_id">
                            <el-radio
                                    v-for="(item, index) in storeOptions"
                                    :key="item.store_id"
                                    :label="item.store_id"
                                    :disabled="item.disabled"
                            >{{item.store_name}}
                            </el-radio>
                        </el-radio-group>
                    </div>
                </el-form-item>
                <el-form-item label="KEY">
                    <el-input v-model="form.client_key"></el-input>
                </el-form-item>
                <el-form-item label="秘钥">
                    <el-input v-model="form.client_secret"></el-input>
                </el-form-item>
                <el-form-item label="来客门店id">
                    <el-input v-model="form.poi_id"></el-input>
                </el-form-item>
                <el-form-item>
                    <el-button @click="submitEvent" type="primary">
                        提交
                    </el-button>
                    <el-button @click="goBack" type="warning">
                        返回
                    </el-button>
                </el-form-item>
            </el-form>
        </div>
    </el-card>
</div>

<script>
    const App = {
        data() {
            return {
                form: {},
                storeOptions: [],
            }
        },
        mounted() {
            this.getInfo()
        },
        computed: {},
        methods: {

            /**
             * 获取编辑所需信息
             */
            getInfo() {
                let tiktok_id = this.getUrlQuery('tiktok_id', 0)
                this.httpGet("{:url('admin/tiktok/edit')}/" + tiktok_id, {}).then(res => {
                    if (res.status) {
                        let {tiktok = {}, storeOptions = {}} = res.data
                        this.storeOptions = storeOptions
                        if (tiktok.tiktok_id) {

                            this.form = {
                                ...tiktok,
                            }
                        }
                    }
                })
            },
            /**
             * 提交信息
             */
            submitEvent() {
                this.httpPost("{:url('admin/tiktok/edit')}", {
                    ...this.form,
                }, true).then(res => {
                    if (res.status) {
                        this.$message.success(res.msg)
                        location.href = "{:url('admin/tiktok/index')}"
                    }
                })
            },
            refresh() {
                location.replace(location.href);
            },
            goBack() {
                window.history.back();
            }
        }
    }
</script>

<style>
</style>
